# 了解$DebugPreference
Write-Debug "Cannot open file."

# 更改$DebugPreference的值
$DebugPreference
Write-Debug "Cannot open file."

$DebugPreference = "Continue"
Write-Debug "Cannot open file."

# 使用Debug参数替代$DebugPreference
function Test-Debug{
    [CmdletBinding()]
    param()
    Write-Debug ('$DebugPreference is ' + $DebugPreference)
    Write-Host ('$DebugPreference is ' + $DebugPreference)
}

Test-Debug

Test-Debug -Debug

$DebugPreference

